//TestScene
//Created: 20/12/12
//Version 1.0
//Created By Daniel Bowler
//
//TestScene is one of the scenes inside this rendering engine / rendering demo.
//Its main purpose will be to show the task I am currently working on before
//migrating the code to another scene. (So the idea is to finish the demonstration
//and then move the code in to a seperate class. Rinse and repeat)
//
//NOTE: We MUST make sure we are safely using pointers. For every single
//scene, ensure that we are both setting all pointers to NULL in the constructor 
//and ensuring that we test for null before deleting dynamic data and then
//setting it back to NULL after deleting. As it turns out, my scene loading &
//unloading method can result in a scene having its DeallocateDynamicData
//function called even if the scene has not had its AllocateDynamicData
//function called before hand. The best way to prevent horrible crashes
//when the SceneManager is released (When the game is closed), is to ENSURE
//YOU USE POINTERS SAFELY. 

#pragma once

#include "AbstractScene.h"

#define NUM_LIGHTS 1024

//Should render text and 2D sprite?
//#define RENDER_2D_SPRITES

class SkyDome;
class OceanAdvModel;
class InlandWaterAdvModel;
class Terrain;

class TestScene : public AbstractScene
{
public: 
	//Constructor and Destructor. Constructor will be used
	//to init the classes variables (and any pointers to NULL) but leave
	//dynamic allocation to the InitDynamicData() - unless absolutly required
	TestScene();
	~TestScene();

	//Override the init and dealloc functions
	void OpenScene();
	void CloseScene();

	//Override the mouse input functions
	void OnMouseDown(WPARAM btnState, int x, int y, UINT originalMessage);
	void OnMouseUp(WPARAM btnState, int x, int y, UINT originalMessage);
	void OnMouseMove(WPARAM btnState, int x, int y);

	//Override OnResize function. 
	void OnResize();

	//Override the render and update functions
	void UpdateWithDelta(float delta);
	void RenderScene();
private:
	StaticModel* mod;
	StaticModel* objMod;
	StaticModel* asimpMod;
	StaticModel* loadedMod;
	StaticModel* teapotMod;

	StaticInstancedModel* iMod;
	StaticInstancedModel* iObjMod;
	StaticInstancedModel* iAsimpMod;

	AnimatedModel* animMod;

	//Advanced models.
	OceanAdvModel* ocean;
	InlandWaterAdvModel* inlandWater;

	//Terrain adv model.
	Terrain* terrain;

	SkyDome* skyDome;

	//Scene State.
	enum SceneState 
	{ 
		SCENE_STATE_DRAW_SCENE,						//Draws as usual
		SCENE_STATE_DRAW_Z_PRE_PASS_DEPTH_BUFFER,   //Draws depth buffer as full screen quad.
		SCENE_STATE_DRAW_CS_MAX_Z_DEPTH_BUFFER,     //(Optional) Draws tile max z Buffer.
		SCENE_STATE_DRAW_CS_LLSEB_GREYSCALE,		//Visualise how many lights affect a tile. 
		SCENE_STATE_DRAW_CS_LLSEB_COLOUR,           //As above, but with more colour.
		SCENE_STATE_DRAW_CS_LLSEBT_GREYSCALE,       //Transparant tiles - greyscale.
		SCENE_STATE_DRAW_CS_LLSEBT_COLOUR,			//Transparant tiles - colour
		SCENE_STATE_DRAW_SSAO_VIEW_NORMALS,			//Draws view space normal tex (SSAO)
		SCENE_STATE_DRAW_SSAO_VIEW_DEPTHS,			//Draws view space depths (SSAO)
		SCENE_STATE_DRAW_SSAO_MAP,					//Draws SSAOMap.   
		SCENE_STATE_DRAW_SHADOW_DEPTH				//Draws shadow map DSV 
	};
	//Scene State - what to render?
	SceneState sceneState;
	//Should render lights?
	bool shouldRenderLights;

	//Render animating model in rigged pose?
	bool shouldRenderAnimModRigged;

	//Direc light
	DirectionalLight dLight;

	//Shadow map bounds. 
	ShadowMapBoundingSphere sceneBounds;

	//2D rendering
	FontSheet* font;
	SpriteBatch* spriteBatch;
	ID3D11ShaderResourceView* tex2D;
};